const app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        navTo: '',
        marginTop: '',
        name: '',
        tableList: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        console.log(options)
        let that = this
        that.setData({
            name: options.name,
            marginTop: app.globalData.statusBarHeight + 'px',
            navTo: app.globalData.navHeight + 'px'
        })
    },
    Gotback() {
        wx.navigateBack({
            delta: 1,
        })
    },
    addTable() {

    },
    addTable(e) {
        console.log(e)
        this.setData({
            modalName: e.currentTarget.dataset.target
        })
    },
    hideModal(e) {
        this.setData({
            modalName: null
        })
    },
    sendfangleiTable(e) {
        let that = this;
        // let sendTabledata = {
        //     "unitname": e.detail.value.unitname,
        //     "unitadd": e.detail.value.unitadd,
        //     "statutoryman": e.detail.value.statutoryman,
        //     "safetyman": e.detail.value.safetyman,
        //     "safty_phone": e.detail.value.safty_phone,
        //     "technicman": e.detail.value.technicman,
        //     "technic_phone": e.detail.value.technic_phone,
        //     "unit_property": e.detail.value.unit_property,
        //     "company_name": e.detail.value.company_name,
        //     "company_add": e.detail.value.company_add,
        // }
        let tableList = that.data.tableList
        tableList.push({
            "unitname": e.detail.value.unitname,
            "unitadd": e.detail.value.unitadd,
            "statutoryman": e.detail.value.statutoryman,
            "safetyman": e.detail.value.safetyman,
            "safty_phone": e.detail.value.safty_phone,
            "technicman": e.detail.value.technicman,
            "technic_phone": e.detail.value.technic_phone,
            "unit_property": e.detail.value.unit_property,
            "company_name": e.detail.value.company_name,
            "company_add": e.detail.value.company_add,
        })
        e.detail.value.unitname = ""
        that.setData({
            tableList,
            modalName: null
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})